package com.zelin.yang.kotlin_demo.weight

import android.content.Context
import android.support.v4.view.ViewPager
import android.util.AttributeSet
import android.view.MotionEvent

class MyViewPager(context: Context, attrs: AttributeSet?) : ViewPager(context, attrs) {

    var isCanScroll:Boolean? = true
    override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
        return if (isCanScroll == false) {
            false
        } else {
            super.onInterceptTouchEvent(ev)
        }
    }

    override fun onTouchEvent(ev: MotionEvent?): Boolean {
        return if (isCanScroll == false) {
            false
        } else {
            super.onTouchEvent(ev)
        }
    }

    fun setScanScroll(isCanScroll : Boolean){
        this.isCanScroll = isCanScroll
    }
}